﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Img
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

            RenderTargetBitmap bp = new RenderTargetBitmap(
                (int)img.Width, (int)img.Height, 96, 96, PixelFormats.Pbgra32);
            DrawingVisual dv = new DrawingVisual();

            using (DrawingContext ctx = dv.RenderOpen())
            {
                var f = new FormattedText("江振", System.Globalization.CultureInfo.CurrentCulture,
                    FlowDirection.LeftToRight, new Typeface("宋体"),
                    14, Brushes.Black);
                f.TextAlignment = TextAlignment.Left;

                ctx.DrawText(f, new Point(20, 0));
            }
            bp.Render(dv);
            img.Source = bp;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            label2.FontFamily = new FontFamily("方正卡通简体");
        }
    }
}
